package com.example.medicine.controller;



import com.example.medicine.Bean.SystemFunction;
import com.example.medicine.Mapper.SystemFunctionMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
@Slf4j
@RestController
@RequestMapping("/systemfunction")
public class SystemFunctionController {
    @Autowired
    private SystemFunctionMapper systemfunctionMapper;

    /**
     * 接收teamList请求，返回数据库的Team表内的所有内容，格式为json
     *
     * @return
     */
@RequiresPermissions("功能管理")
    @GetMapping("/")
    public List<SystemFunction> getSystemFunctionMapperList(){
    log.info("getSystemFunctionMapperList获取功能信息");
    return systemfunctionMapper.getAll();
    }

    /**
     * 接收insertTeam请求，向Team中插入内容
     */
    @RequiresPermissions("功能管理")
    @PostMapping("/")
    public void insertSystemFunction(@RequestBody SystemFunction systemfunction){
        log.info("getSystemFunctionMapperList功能信息添加start");
        systemfunctionMapper.insert(systemfunction);
        log.info("getSystemFunctionMapperList功能信息添加end");
    }

    /**
     * 接收updateTeam请求，根据ID值更新Team内容
     */
    @RequiresPermissions("功能管理")
    @PutMapping("/")
    public void updateSystemFunction(@RequestBody SystemFunction SystemFunction){
        log.info("updateSystemFunction修改功能信息start");
        systemfunctionMapper.update(SystemFunction);
        log.info("updateSystemFunction修改功能信息end");
    }
    @RequiresPermissions("功能管理")
    @DeleteMapping("/{id}")
    public void deleteSystemFunction(@PathVariable String id){
        log.info("deleteSystemFunction功能信息删除");
        systemfunctionMapper.deleteById(id);
    }
}
